package com.roocon.design_pattern.chapter08_active_object;

public class Worker implements ActiveTask {

  @Override public Result doWorkForResult(int count, char fillChar) {
    char[] buf = new char[count];
    for (int i = 0; i < count; i++) {
      buf[i] = fillChar;
      try {
        Thread.sleep(10);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
    return new RealResult(new String(buf));
  }

  @Override public void doWork(String content) {
    try {
      System.out.println("Display:" + content);
      Thread.sleep(10);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }
}
